package com.dc.refactoring._2_在对象之间搬移特性._1_MoveMethod.newObject.methodOne;

/**
 * Description: 搬移函数_删除委托关系
 * @author: gdc
 * @date: 2020/11/14
 * @version 1.0
 */
public class Account2 {
    private AccountType accountType;
    private int daysOverdrawn;

    /**
     * 计算手续费，没有透支时为4.5，有透支时=4.5+透支金额
     */
    public double bankCharge() {
        double result = 4.5;
        if (daysOverdrawn > 0) {
            // 将源函数重新定向
            result += accountType.overdraftCharge(daysOverdrawn);
        }
        return result;
    }
}
